package com.isdepci.project.result.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.isdepci.framework.aspectj.lang.annotation.Log;
import com.isdepci.framework.aspectj.lang.enums.BusinessType;
import com.isdepci.project.result.domain.ProductEmissions;
import com.isdepci.project.result.service.IProductEmissionsService;
import com.isdepci.framework.web.controller.BaseController;
import com.isdepci.framework.web.domain.AjaxResult;
import com.isdepci.common.utils.poi.ExcelUtil;
import com.isdepci.framework.web.page.TableDataInfo;

/**
 * 按产品划分的排放Controller
 *
 * @author isdepci
 * @date 2023-09-05
 */
@RestController
@RequestMapping("/result/productEmissions")
public class ProductEmissionsController extends BaseController
{
    @Autowired
    private IProductEmissionsService productEmissionsService;

    /**
     * 查询按产品划分的排放列表
     */
    @PreAuthorize("@ss.hasPermi('result:productEmissions:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProductEmissions productEmissions)
    {
        startPage();
        List<ProductEmissions> list = productEmissionsService.selectProductEmissionsList(productEmissions);
        return getDataTable(list);
    }

    /**
     * 导出按产品划分的排放列表
     */
    @PreAuthorize("@ss.hasPermi('result:productEmissions:export')")
    @Log(title = "按产品划分的排放", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ProductEmissions productEmissions)
    {
        List<ProductEmissions> list = productEmissionsService.selectProductEmissionsList(productEmissions);
        ExcelUtil<ProductEmissions> util = new ExcelUtil<ProductEmissions>(ProductEmissions.class);
        return util.exportExcel(list, "productEmissions");
    }

    /**
     * 获取按产品划分的排放详细信息
     */
    @PreAuthorize("@ss.hasPermi('result:productEmissions:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(productEmissionsService.selectProductEmissionsById(id));
    }

    /**
     * 新增按产品划分的排放
     */
    @PreAuthorize("@ss.hasPermi('result:productEmissions:add')")
    @Log(title = "按产品划分的排放", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProductEmissions productEmissions)
    {
        return toAjax(productEmissionsService.insertProductEmissions(productEmissions));
    }

    /**
     * 修改按产品划分的排放
     */
    @PreAuthorize("@ss.hasPermi('result:productEmissions:edit')")
    @Log(title = "按产品划分的排放", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProductEmissions productEmissions)
    {
        return toAjax(productEmissionsService.updateProductEmissions(productEmissions));
    }

    /**
     * 删除按产品划分的排放
     */
    @PreAuthorize("@ss.hasPermi('result:productEmissions:remove')")
    @Log(title = "按产品划分的排放", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(productEmissionsService.deleteProductEmissionsByIds(ids));
    }
}
